<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>后台管理系统</title>
        <meta name="author" content="BaiYY"/>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap-datetimepicker.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
        <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap-datetimepicker.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    </head>
<body>
    <div class="right-sidebar" style="max-width: 1200px;">
        <ul class="nav nav-tabs" style="margin-bottom: 16px" role="tablist">
            <li role="presentation"><a href="agentOnLinePay.html">在线统计</a></li>
            <li role="presentation" class="active"><a href="playerOnlinePay.html">在线明细</a></li>
        </ul>
        <div class="input-group" style="margin-top: 10px;">
            <input type="text" class="form-control" placeholder="请输入充值者的ID" name="search" id="search">
            <span class="input-group-btn">
					<button class="btn btn-default" type="button" id="btn">&emsp;搜索&emsp;</button>
				</span>
        </div>

        <section class="table-responsive">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>游戏ID</th>
                    <th>支付金额</th>
                    <th>支付状态</th>
                    <th>商品编号</th>
                    <th>支付时间</th>
                </tr>
                </thead>
                <tbody id="dataList"></tbody>
            </table>
        </section>
        <div id="playerPage">
            <a href="javascript:void(0)" id="prev">上一页</a>
            <a href="javascript:void(0)" id="page"></a>
            <a href="javascript:void(0)" id="next">下一页</a>
            <span>一共</span>
            <a href="javascript:void(0)" id="totalPage"></a>
            <span>页</span>
        </div>
    </div>
    <script type="text/javascript">
        $("#btn").on("click",function () {
            var uid = $.trim($("#search").val());
            if(uid == '' || uid == null) {
                alert("游戏UID不能为空！");
                window.location.href="{:U('Admin/Main/playerOnlinePay')}";
                return false;
            }
            if(uid.length!= 6) {
                alert("请注意游戏UID的位数");
                window.location.href="{:U('Admin/Main/playerOnlinePay')}";
                return false;
            }
            $.ajax({
                type:"get",
                url:"{:U('Admin/Main/getAgentPay')}",
                success:function (data) {
                   if(data == "error") {
                       alert("暂时没有数据")
                       $("#dataList").html("暂时没有数据");
                   }else{
                       var result = data.indexOf(uid/1);
                       if(result >= 0) {
                           $.ajax({
                               type:'get',
                               url:"{:U('Admin/Main/onLinePayList')}?uid="+uid,
                               success:function (data) {
                                   var count = Math.ceil(data.count/10);
//                                   console.log(data);
                                   if(data != 'error' && data.arr.length > 0) {
                                       var str = '';
                                       var state = '';
                                       for(var i=0;i<data.arr.length;++i) {
                                           if(data.arr[i].status == 0) {
                                               state = '失败';
                                           }else if(data.arr[i].status == 1) {
                                               state = '成功';
                                           }
                                           str += "<tr><td><input type='hidden' value='"+data.arr[i].time+"'/>"+data.arr[i].uid+"</td><td>"+data.arr[i].money+"</td><td>"+state+"</td><td>"+data.arr[i].item+"</td><td class='atime'>"+getLocalTime(data.arr[i].time/1000)+"</td><td>";
                                           $("#exports").show();
                                       }
                                       $("#dataList").html(str);
                                       $("#totalPage").text(count);
                                       $("#page").text(1);
                                       $("#prev").on("click",function (ev) {
                                           var uid = $.trim($("#search").val());
                                           var page = $.trim($("#page").text());
                                           var start = $("#dataList tr:first").find("input").val();

                                           var action = -1;
                                           if(page == 1) {
                                               page = 1;
                                               return false;
                                           }else if($("#page").text() > 1) {
                                               page = page - 1;
                                           }
                                           $.ajax({
                                               type:"post",
                                               url:"{:U('Admin/Main/onLinePayList')}",
                                               dataType:"text",
                                               async:false,
                                               data:{"start":start,"action":action,"page":page,"uid":uid},
                                               success: function (data) {
                                                   console.log(data);
                                                   data = JSON.parse(data);
                                                   if(data != 'error') {
                                                       var str = '';
                                                       var state = '';
                                                       for(var i=0;i<data.arr.length;++i) {
                                                           if(data.arr[i].status == 0) {
                                                               state = '失败';
                                                           }else if(data.arr[i].status == 1) {
                                                               state = '成功';
                                                           }
                                                           str += "<tr><td><input type='hidden' value='"+data.arr[i].time+"'/>"+data.arr[i].uid+"</td><td>"+data.arr[i].money+"</td><td>"+state+"</td><td>"+data.arr[i].item+"</td><td class='atime' data-time='"+data.arr[i].time+"'>"+getLocalTime(data.arr[i].time/1000)+"</td></tr>";
                                                       }
                                                       $("#dataList").html(str);
                                                       $("#page").text(page);
                                                   }else{
                                                       $("#dataList").html("暂时没有数据");
                                                   }
                                               }
                                           })
                                       });
                                       $("#next").on("click",function (ev) {
                                           var uid = $.trim($("#search").val());
                                           var page = $.trim($("#page").text());
                                           var start = $("#dataList tr:last").find("input").val();
                                           var action = 1;

                                           page = ++page;
                                           var totalPage = $.trim($("#totalPage").text())/1;
                                           if(page > totalPage) {
                                               return false;
                                           }
                                           $.ajax({
                                               type:"post",
                                               url:"{:U('Admin/Main/onLinePayList')}",
                                               async:false,
                                               dataType:"text",
                                               data:{"start":start,"action":action,"page":page,"uid":uid},
                                               success: function (data) {
//                                                   console.log(data);
                                                   data = JSON.parse(data);
                                                   if(data != 'error') {
                                                       var str = '';
                                                       var state = '';
                                                       for(var i=0;i<data.arr.length;++i) {
                                                           if(data.arr[i].status == 0) {
                                                               state = '失败';
                                                           }else if(data.arr[i].status == 1) {
                                                               state = '成功';
                                                           }
                                                           str += "<tr><td><input type='hidden' value='"+data.arr[i].time+"'/>"+data.arr[i].uid+"</td><td>"+data.arr[i].money+"</td><td>"+state+"</td><td>"+data.arr[i].item+"</td><td class='atime'>"+getLocalTime(data.arr[i].time/1000)+"</td></tr>";
                                                       }
                                                       $("#dataList").html(str);
                                                       $("#page").text(page);
                                                   }else{
                                                       $("#dataList").html("暂时没有数据");
                                                   }
                                               },
                                               error:function (err) {
                                                   console.log(111);
                                                   console.log(err);
                                               }
                                           })
                                       });
                                   }else{
                                       $("#dataList").html("暂时没有数据");
                                   }
                               }
                           });
                       }else{
                           alert("该玩家不是你的下级玩家不能查询");
                           window.location.href="{:U('Admin/Main/playerOnlinePay')}";
                       }
                   }
                }
            })
        })


    </script>
</body>
</html>